package com.example.demo.controller;


import com.example.demo.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("test")
public class ParamController {
    @GetMapping("/get1")
    public String  get1(){
        System.out.println("");
        return  "example/hello";
    }

    @GetMapping("/get2/{id}")
    public String  get2(@PathVariable("id") Integer id){
        System.out.println(id);
        return  "example/hello";
    }

    @GetMapping("/get3")
    public String  get3(String  username){
        System.out.println(username);
        return  "example/hello";
    }

    @GetMapping("/get4")
    public String  get3(User user){
        System.out.println(user);
        return  "example/hello";
    }

    @PostMapping("/post1")
    public String post1(User user){
        System.out.println(user);
        return "example/hello";
    }
    @PostMapping("/post2")
    public String post2(@RequestBody List<User> list){
        System.out.println(list);
        return "example/hello";
    }
    @PostMapping("/post3")
    @ResponseBody
    public List<User> post3(@RequestBody List<User> list){
        System.out.println(list);
        return list;
    }
    @GetMapping("/get5")
    public  String get5(HttpServletRequest request, HttpSession session){
        System.out.println(request.getParameter("name"));
        System.out.println(session);
        System.out.println(request.getSession());
        return "example/hello";

    }
}
